package com.pubsys.main.client.aplicacao;

import java.util.HashMap;

import com.pubsys.main.client.paginas.consulta.PaginaConsulta;
import com.pubsys.main.client.paginas.insercao.Insercao;
import com.pubsys.main.client.paginas.inserir.PaginaInsercao;
import com.pubsys.main.client.paginas.login.PaginaLogin;
import com.pubsys.main.client.paginas.paginaentrada.PaginaEntrada;

/**
 * This class is used to store token strings to all possible places
 * we may navigate in this application, and to provide history control 
 * support for the application (back and forth buttons of the browser)
 * These constants and the tokenizer are used within the AppController, to
 * provide the application with the correct view according to the current 
 * history token (browser link)
 * 
 * @author Martin Reus
 *
 */
public final class ActivityFactory {
	public static final String CONSULTA = "consulta";
	public static final String PRINCIPAL = "principal";
	public static final String LOGIN = "login";
	public static final String INSERCAO = "insercao";
	public static final String INSERE = "insere";
	
	/**
	 * no constructor should be used
	 */
	private ActivityFactory() {
	}


	public static Activity makeFromBrowserHistory(String anchorToken, HashMap<String, String> parameters){		
		
		Activity activity = null;
		
		
		if (anchorToken.equals(CONSULTA)){
			activity = new PaginaConsulta();
		}else if(anchorToken.equals(LOGIN)){
			activity = new PaginaLogin();
		}else if (anchorToken.equals(INSERE))
			activity = new Insercao();
		else
			activity = new PaginaEntrada();
		
				
		if (activity != null){
			activity.setActivityParametersFromHistoryToken(parameters);
			activity.start();
		}
		
		return activity;
	}
	
	
		
}
